package com.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableRabbit
public class RabbitConfig {

    @Bean("exchange")
    public FanoutExchange defaultExchange() {
        return new FanoutExchange("exchange");
    }

    @Bean
    public Binding binding(@Qualifier ("exchange") FanoutExchange exchange, @Qualifier ("messageQuen") Queue queue) {
        return BindingBuilder.bind(queue).to(exchange);
    }

    @Bean("messageQuen")
    public Queue getQueue(){
        return new Queue("messageQuen") ;
    }

}
